﻿using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using WPFCABShell.$safeprojectname$.Interface.Services.Options;

namespace WPFCABShell.$safeprojectname$
{
	public partial class DefaultSkin : ResourceDictionary
	{
		public DefaultSkin()
		{
			Add("PluginItemTemplateSelector", new PluginItemTemplateSelector(this));
			InitializeComponent();
		}

		private sealed class PluginItemTemplateSelector : DataTemplateSelector
		{
			private readonly ResourceDictionary _resourceDictionary;

			public PluginItemTemplateSelector(ResourceDictionary resourceDictionary)
			{
				_resourceDictionary = resourceDictionary;
			}

			public override DataTemplate SelectTemplate(object item, DependencyObject container)
			{
				Debug.Assert(item is IPluginInfo);
				IPluginInfo pluginInfo = item as IPluginInfo;

				if (pluginInfo.IsImplicitlyTrusted)
				{
					return _resourceDictionary["TrustedPluginDataTemplate"] as DataTemplate;
				}
				else
				{
					return _resourceDictionary["UntrustedPluginDataTemplate"] as DataTemplate;
				}
			}
		}
	}
}
